{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from time import sleep\n",
    "from selenium import webdriver\n",
    "from selenium.webdriver.chrome.options import Options\n",
    "executable_path = '/Users/waltersun/Desktop/chromedriver'  # path to your executable browser\n",
    "options = Options()\n",
    "browser = webdriver.Chrome(options=options, executable_path=executable_path)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = 'https://openreview.net/group?id=ICLR.cc/2020/Conference#all-submissions'\n",
    "browser.get(url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_id_list = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "done = False\n",
    "page = 1\n",
    "while not done:\n",
    "    print('Page: {}'.format(page))\n",
    "    for item in browser.find_elements_by_class_name(\"note\"):\n",
    "        data_id = item.get_attribute('data-id') \n",
    "        data_id_list.append(data_id)\n",
    "\n",
    "    right_arrow = browser.find_elements_by_class_name(\"right-arrow\")\n",
    "    if len(right_arrow) > 0:        \n",
    "        browser.execute_script(\"arguments[0].click();\", right_arrow[0])\n",
    "        sleep(5)\n",
    "        page += 1\n",
    "    else:\n",
    "        done = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_id_list = list(set(data_id_list))\n",
    "print('Number of submission: {}'.format(len(data_id_list)))\n",
    "with open('urls.txt', 'w') as urls_txt:\n",
    "    for data_id in data_id_list:\n",
    "        urls_txt.write('https://openreview.net/forum?id={}\\n'.format(data_id))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
